package com.example.demomcp.service;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.databind.util.JSONPObject;

//import org.springframework.ai.mcp.server.autoconfigure.McpServerProperties;
//import org.springframework.ai.autoconfigure.mcp.server.McpServerProperties;
//import org.springframework.ai.autoconfigure.mcp.server.McpServerProperties;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

@Service
public class WeatherService {
    @Autowired(required = false)
//    private McpServerProperties mcpServerProperties;
    @Tool(description = "获取城市的温度")
    public String getWeather(@ToolParam(required = true,description = "城市名称")
                                         String cityName){
//        boolean stdio = mcpServerProperties.isStdio();
//        System.out.println("stdio = " + stdio);
        Map<String, String> getenv = System.getenv();
        for (Map.Entry<String, String> entry : getenv.entrySet()) {
            System.out.println(entry.getKey() + " = " + entry.getValue());
        }
//        HashMap<String, Object> stringObjectHashMap = new HashMap<>();
//        stringObjectHashMap.put("cityName", cityName);
//        stringObjectHashMap.put("xq", "今天的温度是" + "10度"); // 移除不必要的转义字符

        // 创建 JSONPObject 实例并调用其 toString 方法
//        JSONPObject jsonPObject = new JSONPObject("callback", stringObjectHashMap);
        return "今天的温度是" + "10度"; // 返回 JSONP 格式的字符串
    }
//    @Tool(description = "获取我的订单信息")
//    public String getFl(@ToolParam(required = true,description = "我的订单号")
//                                     String cityName){
//
//        return  cityName + "这个案件" + cityName.length()  +"没啥啥事儿";
//    }
}
